import { RewardItem } from "./RewardItem";
import { ObjCreate } from "../../common/ObjCreate";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { ColorConfig } from "../../../resource/ColorConfig";
import { SReward } from "../../../../../Message/Public/SReward";
import { EReward } from "../../../../../Message/Public/EReward";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
import { GBitmap } from "../../../../../com/mui/controls/GBitmap";
type int = number;
//class RewardLabel2
    
    export  class RewardLabel2 extends RewardItem
    {
        constructor()
        {
            super();
            return;
        }

        protected /* override */ createDisposedChildrenImpl(): void
        {
            super.createDisposedChildrenImpl();
            this._rewardLable = ObjCreate.createGTextField();
            this._rewardLable.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._rewardLable.selectable = false;
            this._rewardLable.textColor = 11661311;
            this._rewardLable.filters = [FilterConst.nameGlowFilter];
            addChild(this._rewardLable);
            return;
        }

        protected /* override */ disposeImpl(arg1: Boolean=true): void
        {
            this._rewardLable.dispose();
            super.disposeImpl();
            return;
        }

        public /* override */ set expColor(arg1: int)
        {
            this._expColor = arg1;
            if (this._expColor != -1) 
            {
                this._rewardLable.htmlText = HTMLUtil.addColor(this._rewardLable.text, ColorConfig.instance.getItemColor(this._expColor).color);
            }
            return;
        }

        public /* override */ updateData(arg1: SReward): void
        {
            var loc1=null;
            this.removeBmp();
            var loc2=arg1.type;
            switch (loc2) 
            {
                case EReward._ERewardCoin:
                {
                    this._rewardLable.text = arg1.num.toString();
                    this._rewardBmp = GlobalClass.getBitmap(ImagesConst.Tongqian_small);
                    this._rewardBmp.y = 2;
                    this._rewardBmp.x = this._rewardLable.textWidth + 8;
                    addChild(this._rewardBmp);
                    break;
                }
                case EReward._ERewardCoinBind:
                {
                    this._rewardLable.text = arg1.num.toString();
                    this._rewardBmp = GlobalClass.getBitmap(ImagesConst.Tongqian_bind_small);
                    this._rewardBmp.y = 2;
                    this._rewardBmp.x = this._rewardLable.textWidth + 8;
                    addChild(this._rewardBmp);
                    break;
                }
                default:
                {
                    loc1 = GameDefConfig.instance.getRewardDef(arg1.type);
                    if (loc1) 
                    {
                        this._rewardLable.htmlText = HTMLUtil.addColor(arg1.num + loc1.name.split("　").join(""), "#b1efff");
                    }
                }
            }
            return;
        }

        /* internal  */removeBmp(): void
        {
            if (this._rewardBmp && contains(this._rewardBmp)) 
            {
                this._rewardBmp.dispose();
            }
            return;
        }

        public /* override */ dispose(arg1: Boolean=true): void
        {
            this._expColor = -1;
            super.dispose();
            return;
        }

        public /* override */ get height(): number
        {
            return this._rewardLable.textHeight + 4;
        }

        /* internal */ /* var */_rewardLable: GTextFiled;

        /* internal */ /* var */_rewardBmp: GBitmap;

        /* internal */ /* var */_expColor: int=-1;
    }
